home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Alles Voor Internet / Tout Pour Internet
/
alles voor internet.iso
/
MacInternet™
/
Telnet
/
NCSA
/
tn3270 2.3d26 source
/
SPPC
/
sppc.c.mpw2
< prev
next >
Wrap
Text File
|
1991-05-24
|
4KB
|
183 lines
#include <Devices.h>
#include <Files.h>
#include <String.h>
#include "sppcinterface.h"
static short sppcrefnum = 0; /* driver reference number */
OSErr getsppcref(void); /* routine to get driver number */
OSErr SPPCRegister(unsigned char *myName, short *myRefNum)
{
OSErr rc;
CntrlParam pbr;
parmrec pmr, *pmrptr;
/* initialize for all calls */
rc = getsppcref();
if (rc != noErr) return(rc);
memset(&pbr, 0, sizeof(CntrlParam));
pbr.ioCRefNum = sppcrefnum;
pmrptr = &pmr;
memcpy(pbr.csParam, &pmrptr, 4);
memset (&pmr, 0, sizeof(parmrec));
/* definitions for this call */
pbr.csCode = 1;
pmr.name = myName;
pmr.refptr = myRefNum;
return(PBControl(&pbr, 0));
}
OSErr SPPCDeRegister(short myRefNum)
{
OSErr rc;
CntrlParam pbr;
parmrec pmr, *pmrptr;
/* initialize for all calls */
rc = getsppcref();
if (rc != noErr) return(rc);
memset(&pbr, 0, sizeof(CntrlParam));
pbr.ioCRefNum = sppcrefnum;
pmrptr = &pmr;
memcpy(pbr.csParam, &pmrptr, 4);
memset (&pmr, 0, sizeof(parmrec));
/* definitions for this call */
pbr.csCode = 2;
pmr.refnum = myRefNum;
return(PBControl(&pbr, 0));
}
OSErr SPPCLookup(unsigned char *appName, short *itsRefNum)
{
OSErr rc;
CntrlParam pbr;
parmrec pmr, *pmrptr;
/* initialize for all calls */
rc = getsppcref();
if (rc != noErr) return(rc);
memset(&pbr, 0, sizeof(CntrlParam));
pbr.ioCRefNum = sppcrefnum;
pmrptr = &pmr;
memcpy(pbr.csParam, &pmrptr, 4);
memset (&pmr, 0, sizeof(parmrec));
/* definitions for this call */
pbr.csCode = 3;
pmr.name = appName;
pmr.refptr = itsRefNum;
return(PBControl(&pbr, 0));
}
OSErr SPPCSend(short myRefNum, short toRefNum,
unsigned long replyId, Handle theMessage,
unsigned short msgLength, unsigned long *msgId)
{
OSErr rc;
CntrlParam pbr;
parmrec pmr, *pmrptr;
/* initialize for all calls */
rc = getsppcref();
if (rc != noErr) return(rc);
memset(&pbr, 0, sizeof(CntrlParam));
pbr.ioCRefNum = sppcrefnum;
pmrptr = &pmr;
memcpy(pbr.csParam, &pmrptr, 4);
memset (&pmr, 0, sizeof(parmrec));
/* definitions for this call */
pbr.csCode = 4;
pmr.refnum = myRefNum;
pmr.refnum2 = toRefNum;
pmr.replyid = replyId;
pmr.msg = theMessage;
pmr.msglen = msgLength;
pmr.msgid = msgId;
return(PBControl(&pbr, 0));
}
OSErr SPPCGet(short myRefNum, short *fromRefNum,
unsigned long replyId, Handle theMessage,
unsigned short *msgLength, unsigned long *msgId,
unsigned long *replyIdPtr)
{
OSErr rc;
CntrlParam pbr;
parmrec pmr, *pmrptr;
/* initialize for all calls */
rc = getsppcref();
if (rc != noErr) return(rc);
memset(&pbr, 0, sizeof(CntrlParam));
pbr.ioCRefNum = sppcrefnum;
pmrptr = &pmr;
memcpy(pbr.csParam, &pmrptr, 4);
memset (&pmr, 0, sizeof(parmrec));
/* definitions for this call */
pbr.csCode = 5;
pmr.refnum = myRefNum;
pmr.refptr = fromRefNum;
pmr.replyid = replyId;
pmr.msg = theMessage;
pmr.msglenptr = msgLength;
pmr.msgid = msgId;
pmr.replyidptr = replyIdPtr;
return(PBControl(&pbr, 0));
}
OSErr SPPCClear(short myRefNum)
{
OSErr rc;
CntrlParam pbr;
parmrec pmr, *pmrptr;
/* initialize for all calls */
rc = getsppcref();
if (rc != noErr) return(rc);
memset(&pbr, 0, sizeof(CntrlParam));
pbr.ioCRefNum = sppcrefnum;
pmrptr = &pmr;
memcpy(pbr.csParam, &pmrptr, 4);
memset (&pmr, 0, sizeof(parmrec));
/* definitions for this call */
pbr.csCode = 6;
pmr.refnum = myRefNum;
return(PBControl(&pbr, 0));
}
OSErr SPPCDeleteMsg(unsigned long *msgId)
{
OSErr rc;
CntrlParam pbr;
parmrec pmr, *pmrptr;
/* initialize for all calls */
rc = getsppcref();
if (rc != noErr) return(rc);
memset(&pbr, 0, sizeof(CntrlParam));
pbr.ioCRefNum = sppcrefnum;
pmrptr = &pmr;
memcpy(pbr.csParam, &pmrptr, 4);
memset (&pmr, 0, sizeof(parmrec));
/* definitions for this call */
pbr.csCode = 7;
pmr.msgid = msgId;
return(PBControl(&pbr, 0));
}
OSErr getsppcref()
{
ParamBlockRec pbr;
OSErr rc;
if (sppcrefnum != 0) return(noErr);
memset(&pbr, 0, sizeof(ParamBlockRec));
pbr.ioParam.ioNamePtr = "\p.SPPC";
rc = PBOpen(&pbr, 0);
if (rc == noErr) {
sppcrefnum = pbr.ioParam.ioRefNum;
}
return(rc);
}